<div class="panel" id="nav">
<div class="panel-heading"><h3 class="panel-title">备货需求汇总列表</h3></div>
<div class="panel-body">
    <form action="Inbound/Prepareneeds/index" id="search-form" class="search-form">
        <div class="container-fluid">

            <div class="col-sm-12 col-md-4  add-space">
                        <div class="input-group input-group-md">
                            <span class="input-group-addon">备货需求批次号</span>
                            <input class="form-control " placeholder="请输入内容" name="batch_code"
                                   data-name-group="" type="text" value="">
                        </div>
                    </div>
                    <div class="col-sm-12 col-md-3  add-space">
                        <div class="input-group input-group-md">
                            <span class="input-group-addon">状态</span>
                            <select class="chosen-select form-control" tabindex="-1" name="status"
                                    data-name-group="common">
                                <option value="" class="empty-opt">-- 请选择 --</option>
                                <volist name="orderState" id="item">
                                    <option value="{$key}" >{$item}</option>
                                </volist>
                            </select>
                        </div>
                    </div>
                    <div class="col-sm-12 col-md-3 add-space">
                        <div class="input-group input-group-md">
                            <span class="input-group-addon">中转仓</span>
                            <select class="chosen-select form-control" tabindex="-1" name="transfer_hopper_id"
                                    data-name-group="common">
                                <option value="" class="empty-opt">-- 请选择 --</option>
                                <volist name="transfer" id="item">
                                    <option value="{$item.id}" >{$item.name}</option>
                                </volist>
                            </select>
                        </div>
                    </div>
                    <div class="col-sm-12 col-md-6  add-space">
                        <div class="input-group input-group-md">
                            <span class="input-group-addon">创建时间</span>
                            <input class="form-control form-datetime_1" type="text" name="create_time_from" style="cursor:pointer;" readonly>
                            <span class="input-group-addon"><span class="icon-calendar"></span></span>
                            <input class="form-control form-datetime_1" type="text" name="create_time_to" style="cursor:pointer;" readonly>
                            <span class="input-group-addon fix-border fix-padding">&nbsp;<span class="text-danger">0</span>天</span>
                        </div>
                    </div>
                <div class="col-md-2 add-space">
                    <input class="btn btn-primary jsSearchBtn" type="submit" value="搜索"></div>

        </div>
    </form>
    <div class="clearfix"></div>
    <hr>
    <?php if(!empty($result)):?>
    <table id="example" class="table table-striped  table-hover" cellspacing="0" width="100%">
        <thead>
        <tr>
            <th width="45">序号</th>
            <th>备货需求批次号</th>
            <th>状态</th>
            <th>上传人</th>
            <th>创建时间</th>
            <th>中转仓库</th>
            <th>备注</th>
            <th width="80">操作</th>
        </tr>
        </thead>
        <tbody>
        <foreach name='result' item='vo'>
        <tr>
            <td>{$i++}</td>
            <td><a href="Inbound/Prepareneeds/all_detail?batch_code={$vo.batch_code}" />{$vo.batch_code}</td>
            <td>{$vo.status}</td>
            <td>{$vo.create_user_id}</td>
            <td>{$vo.create_time}</td>
            <td>{$vo.transfer_hopper_id}</td>
            <td>{$vo.remark}</td>
            <td>
                <div class="dropdown">
                    <button class="btn btn-xs" type="button" data-toggle="dropdown"> 操作<span
                            class="caret"></span></button>
                    <ul class="dropdown-menu">
                        <li><a title="导出明细" href="Inbound/Prepareneeds/single_detail?downcsv=1&batch_code={$vo.batch_code}">导出明细</a></li>
                        <li><a title="查看明细" href="Inbound/Prepareneeds/single_detail?batch_code={$vo.batch_code}&create_user_id={$vo.create_user_id}" data-target=".showdetail">查看明细</a>
                        </li>
                    </ul>
                </div>
            </td>
        </tr>
        </foreach>
        </tbody>
    </table>
    <?php endif?>

    <div class="clearfix clear"></div>
    <div class="row">
        <div class="col-md-6 pull-left">
            <label>每页 20 条记录
                显示 1 到 20 项，共 {$count}项</label>
        </div>
        <div class="col-md-6">
            <div class="page pull-right" style="padding: 0;margin: 0">
                {$page}
            </div>
        </div>
    </div>
  </div>
</div>

<!-------------------------当前页面js引用处--------------------------------->
<?php include 'common/bottom.html' ?>
<script>
    /**
     * 计算日期差
     * khq 2017.1.23
     */
    $('.form-datetime_1').datetimepicker({
        // mask:'9999/19/39 29:59',
        lang:'ch',
        onChangeDateTime:function(dp,$input){
            //alert(dp);
            date_needs();
        },
        onSelectDate:function()
        {
            date_needs();
        }
    });
    var date_needs =function(){
        var start_time = Date.parse($("input[name=create_time_from]").val());
        var end_time   = Date.parse($("input[name=create_time_to]").val());
        var diff       = end_time-start_time;                         //时间差的毫秒数
        var days=Math.floor(diff/(24*3600*1000));
        //var leave1=diff%(24*3600*1000);                            //计算天数后剩余的毫秒数
        //var hours=Math.floor(leave1/(3600*1000))/24;               //计算出小时数
        if(!isNaN(days))
        $(".text-danger").html(days);
    };

    $(function () {
        $("input[name=batch_code]").val("<?php echo $_GET['batch_code']?>");
        $("select[name=status]").val("<?php echo $_GET['status']?>");
        $("select[name=transfer_hopper_id]").val("<?php echo $_GET['transfer_hopper_id']?>");
        $("input[name=create_time_from]").val("<?php echo $_GET['create_time_from']?>");
        $("input[name=create_time_to]").val("<?php echo $_GET['create_time_to']?>");
        date_needs();
        $('select.chosen-select').chosen({
            no_results_text: '没有找到',    // 当检索时没有找到匹配项时显示的提示文本
            disable_search_threshold: 2, // 10 个以下的选择项则不显示检索框
            search_contains: true         // 从任意位置开始检索
        });
    });
</script>